package com.rgs.ssm.dao;

import com.rgs.ssm.domain.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @create 2021-02-15 16:45
 **/
@Repository
public interface IProductDao{

    /**
     * 添加产品
     * @param product
     */
    @Insert("insert into product(productNum,productName,cityName,departureTime,productPrice,productDesc,productStatus)" +
            "values(#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
    void saveProduct(Product product);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from product where id = #{id}")
    void delete(Integer id);

    /**
     * 修改
     * @param product
     */
    @Update("update product set productNum=#{productNum},productName=#{productName},cityName=#{cityName},departureTime=#{departureTime},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus} where id = #{id}")
    void update(Product product);

    /**
     * 查询所有的商品信息
     * @return
     */
    @Select("select * from product")
    List<Product> findAll();

    /**
     * 查一个
     * @param id
     * @return
     */
    @Select("select * from product where id = #{id}")
    Product findById(Integer id);



}
